[XEN] perf counters: Fix NULL-pointer check. Should happen later.
authorkaf24@localhost.localdomain <kaf24@localhost.localdomain>
Fri, 27 Oct 2006 17:10:37 +0000 (18:10 +0100)
committerkaf24@localhost.localdomain <kaf24@localhost.localdomain>
Fri, 27 Oct 2006 17:10:37 +0000 (18:10 +0100)
Signed-of-by: Kouya Shimura <kouya@jp.fujitsu.com>
xen/common/perfc.c

index 1903ef2f4e667fa93580a342e084965724ba955e..471bd3cd2b9b921edefd955d38eb4d791ce12363 100644 (file)
@@ -143,9 +143,6 @@ static int perfc_copy_info(XEN_GUEST_HANDLE(xen_sysctl_perfc_desc_t) desc,
     unsigned int v = 0;
     atomic_t *counters = (atomic_t *)&perfcounters;
 
-    if ( guest_handle_is_null(desc) )
-        return 0;
-
     /* We only copy the name and array-size information once. */
     if ( !perfc_init ) 
     {
@@ -175,7 +172,11 @@ static int perfc_copy_info(XEN_GUEST_HANDLE(xen_sysctl_perfc_desc_t) desc,
         perfc_vals = xmalloc_array(xen_sysctl_perfc_val_t, perfc_nbr_vals);
         perfc_init = 1;
     }
-    if (perfc_vals == NULL)
+
+    if ( guest_handle_is_null(desc) )
+        return 0;
+
+    if ( perfc_vals == NULL )
         return -ENOMEM;
 
     /* Architecture may fill counters from hardware.  */
@@ -207,9 +208,9 @@ static int perfc_copy_info(XEN_GUEST_HANDLE(xen_sysctl_perfc_desc_t) desc,
     }
     BUG_ON(v != perfc_nbr_vals);
 
-    if (copy_to_guest(desc, (xen_sysctl_perfc_desc_t *)perfc_d, NR_PERFCTRS))
+    if ( copy_to_guest(desc, (xen_sysctl_perfc_desc_t *)perfc_d, NR_PERFCTRS) )
         return -EFAULT;
-    if (copy_to_guest(val, perfc_vals, perfc_nbr_vals))
+    if ( copy_to_guest(val, perfc_vals, perfc_nbr_vals) )
         return -EFAULT;
     return 0;
 }